package com.hzau.tourist_service_sys.comtroller;

import com.hzau.tourist_service_sys.pojo.Emergency;
import com.hzau.tourist_service_sys.result.Result;
import com.hzau.tourist_service_sys.service.EmergencyService;
import com.hzau.tourist_service_sys.ultils.jjwttool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class EmergencyController {

    @Autowired
    EmergencyService emergencyService;
@PostMapping("/Emergency/save")
public Result EmergencySave(@RequestBody Emergency emergency,@RequestHeader("token") String token){
//    System.out.println(emergency);
    Integer userId = jjwttool.getUserId(token);
    emergency.setUserId(Long.valueOf(userId));
    return emergencyService.save(emergency);

}
    @PostMapping("/Emergency/updateStatus")
    public Result updateStatus(@RequestBody Emergency emergency){
        return emergencyService.updateSatus(emergency.getEmergencyId());
    }

    @PostMapping("/Emergency/updateInfo")
    public Result updateInfo(@RequestBody Emergency emergency){

        return emergencyService.updateInfo(emergency);
    }
    @PostMapping("Emergency/deleteById")
    public Result deleteById(@RequestBody Emergency emergency){
    return emergencyService.deleteById(emergency.getEmergencyId());

    }
    @PostMapping("Emergency/select")
    public Result find(@RequestBody Emergency emergency){
    return emergencyService.findPage(emergency);

    }
}
